package com.example.ordersystem.utils;


import com.example.ordersystem.pojo.Food;

import java.util.ArrayList;
import java.util.List;

//这个是对收藏菜品进行添加，删除，以及加入订单操作，将收藏菜品封装到一个 List<Food> 集合中去

public class Like_Food {

    private static List<Food> foodList = new ArrayList<>();

    public static boolean addFood(Food food) {

        List<Food> like_food = Like_Food.getLike_Food();
        for (Food food1 : like_food) {
            if (food1.getImageId() == food.getImageId()) {
                return false;
            }
        }
        foodList.add(food);
        return true;
    }

    public static List<Food> getLike_Food() {
        return foodList;
    }

    public static void deleteFood(Food food) {
        for (Food food1 : foodList) {
            if (food.toString().equals(food1.toString())) {
                foodList.remove(food1);
                break;
            }
        }
    }
}
